<template>
	<view class="banner">
		<view class="banner_nr">
			<view class="banner_top">
				<image src="@/static/images/Home/homeSom/icon/icon-safety.png" alt="" class="safaty"></image>
				<span>安全保障中</span>
			</view>
			<view class="textOne">{{KOI}}KOI</view>
			<view class="textTwo">≈{{aboutUSDT}}USDT</view>
		</view>
	</view>
	<view class="output">
		<view class="producedYesterday">
			<view class="icons">
				<image src="@/static/images/Home/icon/icon-yesterday.png"></image>
			</view>
			<view class="info">
				<view class="name">昨天产出算力</view>
				<view class="num">+12KOI</view>
			</view>
		</view>
		<view class="monthlyOutput">
			<view class="icons">
				<image src="@/static/images/Home/icon/icon-month.png"></image>
			</view>
			<view class="info">
				<view class="name">30天产出算力</view>
				<view class="num">+1207KOI</view>
			</view>
		</view>
	</view>
	<view class="trade">
		<view class="title">交易记录</view>
		<view class="list">
			<view class="item" v-for="(item,index) in transactionHistory" :key="index+1">
				<view class="name">{{item.remark}}</view>
				<view class="time">{{item.createTime}}</view>
				<view :class="'num ' + (item.amount>=0?'correct':'negative')"><template
						v-if="item.amount >=0">+</template>{{item.amount}}</view>
				<view class="tips">{{ }}</view>
			</view>
		</view>
	</view>
</template>

<script lang="ts" setup>
	import { onLoad } from '@dcloudio/uni-app';
	import { ref } from 'vue'
	import { getAssetDetails, getCoinDetailList } from '@/api/userAssets'
	import PaymentSuccess from '../eject/eject.vue';
	// 约等于的USDT
	const aboutUSDT = ref(0)
	// KOI
	const KOI = ref<Number>(0)
	// 交易记录
	const transactionHistory = ref([])
	onLoad(async () => {
		var { data } = await getAssetDetails('KOI')
		KOI.value = data.normalBalance
		aboutUSDT.value = KOI.value / data.priceUsd
		var CoinDetail = await getCoinDetailList({ symbol: "KOI" })
		transactionHistory.value = CoinDetail.rows
		console.log(transactionHistory.value)
	})
</script>

<style lang="scss" scoped>
	.output {
		height: 152px;
		display: flex;
		justify-content: center;

		>.producedYesterday,
		.monthlyOutput {
			&.monthlyOutput {
				padding-left: 72px;
			}

			max-width: 50%;
			height: 152px;
			float: left;
			display: flex;
			align-items: center;
			justify-content: center;

			.icons {
				position: relative;
				width: 72px;
				height: 72px;
				border-radius: 12px;
				margin-right: 16px;
				// opacity: 0.4;''
				border: 1px solid rgba(255, 255, 255, 0.4);

				image {
					position: absolute;
					top: 0;
					right: 0;
					bottom: 0;
					left: 0;
					margin: auto;
					width: 40px;
					height: 40px;
				}
			}

			.info {
				.name {
					font-size: 24px;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					color: RGBA(112, 113, 115, 1);
					line-height: 33px;
				}

				.num {
					font-size: 28px;
					font-family: PingFangSC, PingFang SC;
					font-weight: 600;
					color: #FFFFFF;
					line-height: 36px;
				}
			}
		}
	}

	.banner {
		margin-top: 40px;
		width: 100%;
		height: 240px;
		display: flex;
		justify-content: center;
	}

	.banner_nr {
		margin: 0 auto;
		width: 686px;
		height: 240px;
		background-image: url('../../static/images/Home/homeSom/banner.png');
		background-size: 100% 100%;
	}

	.banner_nr>view:nth-child(n+2) {
		color: white;
		margin: 16px 40px;
	}

	.banner_nr .textOne {
		font-size: 50px;
	}

	.banner_nr .textTwo {
		font-size: 26px;
	}

	.banner_top {
		width: 237px;
		height: 36px;
		margin-top: 24px;
		color: #100F42;
		font-size: 20px;
		display: flex;
		align-items: center;
		line-height: 36px;
		background: linear-gradient(90deg, #14D081 0%, rgba(20, 208, 129, 0) 100%);
	}

	.banner_top .safaty {
		width: 20px;
		height: 24px;
		margin: 0 8px 0 40px;
	}

	.trade {
		width: 686px;
		// max-height: 84vh;
		margin: 0 auto;
		padding: 40px;
		background: rgba(255, 255, 255, 0.1);
		border-radius: 32px;
		color: #ffffff;
		box-sizing: border-box;
		font-size: 36px;
		margin-top: 40px;

		.title {
			font-size: 36px;
			font-family: PingFangSC, PingFang SC;
			font-weight: 600;
			color: #FFFFFF;
			line-height: 50px;
			letter-spacing: 1px;
		}

		.list {
			padding-top: 12px;
			overflow-y: auto;

			.item {
				display: flex;
				justify-content: space-between;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				height: 80px;
				flex-wrap: wrap;
				align-items: center;
				flex-direction: row;
				align-content: center;

				.name {
					font-size: 26px;
				}

				.time {
					color: rgba(127, 127, 129, 1);
					font-size: 24px;
				}

				.num {
					font-size: 26px;

					&.correct {
						color: rgba(247, 181, 0, 1);
					}

					&.negative {
						color: rgba(0, 208, 185, 1);
					}
				}

				.tips {
					width: 100%;
					font-size: 24px;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					color: rgba(119, 120, 122, 1);
					line-height: 33px;
				}
			}
		}
	}
</style>